//
//  NCButtonDemoViewController.swift
//  ZZUIDemo
//
//  Created by 张文晏 on 2018/11/20.
//  Copyright © 2018 Newcoretech. All rights reserved.
//

import UIKit
import ZZUI

class NCButtonDemoViewController: UIViewController {
    
    @IBOutlet var btn1: NCButton!
    @IBOutlet var btn2: NCButton!
    @IBOutlet var btn3: NCButton!
    @IBOutlet var btn4: NCButton!
    @IBOutlet var btn5: NCButton!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let switchBtn = UISwitch()
        switchBtn.addTarget(self, action: #selector(switchAction(_:)), for: .valueChanged)
        navigationItem.rightBarButtonItem = UIBarButtonItem(customView: switchBtn)
        
        title = switchBtn.isOn ? "Enable" : "Disable"
        
        btn1.style = .theme
        btn2.style = .gray
        btn3.style = .warning
        btn4.style = .border
        btn5.style = .module
        
        btn1.isEnabled = switchBtn.isOn
        btn2.isEnabled = switchBtn.isOn
        btn3.isEnabled = switchBtn.isOn
        btn4.isEnabled = switchBtn.isOn
        btn5.isEnabled = switchBtn.isOn
    }
    
    @objc func switchAction(_ sender: UISwitch) {
        title = sender.isOn ? "Enable" : "Disable"
        btn1.isEnabled = sender.isOn
        btn2.isEnabled = sender.isOn
        btn3.isEnabled = sender.isOn
        btn4.isEnabled = sender.isOn
        btn5.isEnabled = sender.isOn
    }
    
}
